<template>
  <!--要客资料-->
  <div class="ziliao">
    <div class="content">
      <span @click="goIndex()">跳过 <img :src="src" alt="" height="10"></span>
    </div>
    <wv-group title="姓名" >
      <wv-input placeholder="请输入真实姓名" v-model="privatedata.userName"></wv-input>
    </wv-group>
    <wv-group title="手机号">
      <wv-input placeholder="请输入手机号" type="number" :maxlength="11" pattern="/^((13|14|15|17|18)[0-9]{1}\d{8})$/" v-model="privatedata.mobile"></wv-input>
    </wv-group>
    <wv-group title="公司名称" >
      <wv-input placeholder="请输入公司名称" v-model="privatedata.companyName"></wv-input>
    </wv-group>
    <wv-group title="地址" >
      <wv-input placeholder="请输入公司地址" v-model="privatedata.companyAddress"></wv-input>
    </wv-group>
    <wv-group title="应急电话" >
      <wv-input placeholder="请输入应急电话" type="number" :maxlength="11" pattern="/^((13|14|15|17|18)[0-9]{1}\d{8})$/"v-model="privatedata.telePhone"></wv-input>
    </wv-group>
    <wv-group title="备注" class="des">
      <wv-textarea placeholder="请输入备注" :rows="6" show-counter max-length="500" v-model="privatedata.remark"></wv-textarea>
    </wv-group>
    <p class="offer" @click="goNext(privatedata)">确定</p>
  </div>
</template>

<script type="text/ecmascript-6">
  import {goPerfectVipcard} from '../../../../test/unit/http'
  import {Toast} from 'we-vue'
    export default {
        name: 'yaokewanshan',
        props: {},
        data() {
            return {
              src: require('../../../assets/arrow.png'),
              privatedata:{}
            };
        },
        methods: {
          checkFrom: function (privatedata) {
            var msg = {};
            if (this.$myUtils.isNull(privatedata.userName)) {
              msg['result'] = false;
              msg['info'] = '请输入真实姓名';
              return msg;
            }
            if (!this.$myUtils.checkUserName(privatedata.userName)) {
              msg['result'] = false;
              msg['info'] = '真实姓名格式不正确';
              return msg;
            }
            if (this.$myUtils.isNull(privatedata.mobile)) {
              msg['result'] = false;
              msg['info'] = '请输入手机号';
              return msg;
            }
            if (!this.$myUtils.checkMobile(privatedata.mobile)) {
              msg['result'] = false;
              msg['info'] = '请输入正确的手机号';
              return msg;
            }
            if (this.$myUtils.isNull(privatedata.companyName)) {
              msg['result'] = false;
              msg['info'] = '请输入公司名称';
              return msg;
            }
            if (this.$myUtils.isNull(privatedata.companyAddress)) {
              msg['result'] = false;
              msg['info'] = '请输入公司地址';
              return msg;
            }
            if (!this.$myUtils.checkMobile(privatedata.telePhone)) {
              msg['result'] = false;
              msg['info'] = '请输入正确的应急电话';
              return msg;
            }
            msg['result'] = true;
            msg['info'] = '校验成功';
            return msg;
          },
          goPerfect(params){
            var type=this.$route.query.type;
            goPerfectVipcard(params).then(res => {
              console.log(res);
              if (res.code == 100) {
                var accountGoods = res.object;
                this.$router.push({path: '/yaofangka', query: {accountGoodsId: accountGoods.accountGoodsId,type:type}})
              }
            })
          },
          goNext(privatedata){
            var accountGoodsId=this.$route.query.accountGoodsId;
            privatedata['dataType']=1;
            privatedata['accountGoodsId']=accountGoodsId;
            var checkResult = this.checkFrom(privatedata);
            if (!checkResult.result) {
              Toast.text(checkResult.info);
              return;
            }
            this.goPerfect(privatedata);
          },
          goIndex(){
            this.$router.push({path:'index'})
          }
        },
        created() {

        },
        components: {}
    }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less" rel="stylesheet/less">
  .des{
    padding-bottom: 65px;
  }
  .content{
    text-align: right;
    padding: 20px 20px 0;
    span{
      color: #fff;
      background-color: rgba(0,0,0,0.2);
      padding: 5px 10px;
      border-radius: 5px;
      img{
        vertical-align: middle;
        margin-bottom: 2px;
      }
    }
  }
  .offer{
    position: fixed;
    bottom: 0;
    width: 100%;
    background-image: linear-gradient(to left, #4c92ed,#61beec);
    height: 50px;
    line-height: 50px;
    color: #fff;
    z-index: 999;
  }

</style>
